<?php

namespace App\Models\Train\TrainOrders\Repositories\Interfaces;

use App\Models\Orders\Orders;
use App\Models\Task\SnapTasks\SnapTask;
use App\Models\Train\TrainOrderPassengers\TrainOrderPassenger;
use App\Models\Train\TrainOrders\TrainOrder;
use App\Models\Train\TrainOrderTrain\TrainOrderTrain;
use App\Models\Trip\OrderPay\OrderPay;
use App\Trip\Orders\BookOrders\TaskEdit\TaskEditOrder;
use Illuminate\Support\Collection;

interface TrainOrdersRepositoryInterface
{
    public function lists(array $param, int $page_size): Collection;

    public function listAll(array $param): Collection;


    /**
     * 创建订单
     *
     * @param array $data
     *
     * @return TrainOrder
     */
    public function createTrainOrder(array $data): TrainOrder;

    /**
     * 创建订单
     *
     * @param array $orders
     *
     * @return array
     */
    public function createTrainOrders(array $orders): array;

    /**
     * 创建抢票任务
     *
     * @param array    $data
     * @param SnapTask $task
     *
     * @return TrainOrder
     */
    public function createSnapTaskOrder(array $data, SnapTask $task): TrainOrder;

    /**
     * 创建抢票任务
     *
     * @param array $orders
     * @param array $task_data
     *
     * @return array
     */
    public function createSnapTaskOrders(array $orders, array $task_data): array;

    /**
     * 改签订单
     *
     * @param TrainOrder $origin_order_info
     * @param array      $new_order_data
     *
     * @return TrainOrder
     */
    public function changeTrainOrder(TrainOrder $origin_order_info, array $new_order_data): TrainOrder;

    /**
     * 新改签的订单 取消或失败
     *
     * @param TrainOrder $order
     *
     * @return mixed
     */
    public function orderChangeFailed(TrainOrder $order);

    /**
     * 更新车次到订单（备选）
     *
     * @param TrainOrder      $order
     * @param TrainOrderTrain $train
     *
     * @return bool
     */
    public function saveRealTrain(TrainOrder $order, TrainOrderTrain $train): bool;

    public function getOrderInfo(string $order_sn): ?TrainOrder;

    /**
     * 外部单号 查询关联的全部订单
     *
     * @param string $out_order_sn 订票时 向服务商发送的外部订单单号,比如中转订单 就是一个外部单号 对应两个订单
     *
     * @return Collection
     */
    public function getOrdersByOutOrderSn(string $out_order_sn): Collection;

    public function getOrderInfoByOrder(Orders $order): TrainOrder;

    public function getOrderShowInfo(string $order_sn): array;

    public function getOrderShowInfoDatasByTrainOrder(TrainOrder $order_info): array;

    public function getOrderShowInfoDatasByOrderSn(string $order_sn): array;

    public function cancelOrder(TrainOrder $order, bool $manual): bool;

    public function cancelSnapOrder(TrainOrder $order, bool $manual): bool;

    public function stopTaskOrder(SnapTask $task_info, TrainOrder $order): bool;

    public function destroy(TrainOrder $order): bool;

    public function orderPaid(TrainOrder $order, OrderPay $orderPay);

    public function ticketed(TrainOrder $order, array $data);

    public function updateOrderState(TrainOrder $current_order, array $update_data, Collection $update_passengers = null): bool;

    public function lastOrder(string $user_id): ?TrainOrder;

    public function findOneByTrainData(array $data): ?TrainOrder;

    public function checkSameTripTrainData(array $data): Collection;

    public function saveOutOrderId(TrainOrder $order, string $out_order_id): bool;

    public function saveOrderPaySn(TrainOrder $order, string $pay_sn): bool;

    public function getNotMatchSelectSeats(TrainOrder $order): array;

    public function getChangeOriginOrderNeedRefund(TrainOrder $order): array;

    public function getTripOrders(TrainOrder $order): Collection;

    public function getTripSecondOrder(TrainOrder $first_order): ?TrainOrder;

    public function ticketFailedAndRefund(TrainOrder $order);

    public function passengerApplyRefund(TrainOrderPassenger $passenger);

    public function getOtherChangedOrders(TrainOrder $order, bool $to_show): Collection;

    public function updateSnapOrder(TrainOrder $order, TaskEditOrder $editOrder, ?OrderPay $pay_info = null);

    public function updateOrderSnapState(TrainOrder $order, int $order_snap_state);
}